<%@ page contentType="text/html; charset=ISO-8859-1" language="java" pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.List" %>
<%@ page import="persistency.ServiceCallRepository" %>
<%@ page import="model.ServiceCall" %>

<!DOCTYPE html>
<html>
	<head>
		<title>Service call list</title>
		
		<style type="text/css">
		
			thead {
				background-color: blue;
				color: white;
				height: 2em;
			}
		
		</style>
	</head>

	<body>
		<%
			ServiceCallRepository repository = new ServiceCallRepository();
			List<ServiceCall> serviceCalls = repository.getAll();
		%>
		
		<table>
			<thead>
				<tr>
      				<th>ID</th>
      				<th>Customer</th>
      				<th>Product</th>
      				<th>Description</th>
      				<th>Priority Code</th>
      				<th>Status Code</th>
      				<th>Operator</th>
      				<th>Start time</th>
      				<th>Stop time</th>
   				</tr>
			</thead>
			<tbody>
				<% for (ServiceCall serviceCall : serviceCalls) { %>
				<tr>
					<td><%= serviceCall.getId() %></td>
					<td><%= serviceCall.getCustomer().getName() %>
					<td><%= serviceCall.getProduct().getDescription() %>
					<td><%= serviceCall.getDescription() %>
					<td><%= serviceCall.getPriorityCode() %>
					<td><%= serviceCall.getStatusCode() %>
					<td><%= serviceCall.getOperator().getName() %>
					<td><%= serviceCall.getStartTime() %>
					<td><%= serviceCall.getStopTime() %>
				</tr>
				<% } %>
			</tbody>
		</table>
	</body>
</html>